home *** CD-ROM | disk | FTP | other *** search
- ' IN-TOUCH.BAS
- ' A flat-file database that allows you to enter the names and
- ' phone numbers of business contacts and search for them, then
- ' dial their number using your modem and attached telephone.
-
- DECLARE SUB AddName ()
- DECLARE SUB SearchName ()
- DECLARE SUB DialNumber ()
- OPTION BASE 1
- DIM SHARED Name$(4, 19) ' Array to hold each name and phone number
- DIM SHARED NumNames% ' Number of names found in database
- DIM SHARED HomeAC$ ' Your home area code
- DIM SHARED filename$ ' Name of contacts database file
-
- filename$ = "CONTACTS.TXT"
-
- HomeAC$ = "206" ' Local area code (change when traveling)
-
- ' Display the main menu
- MainMenu:
- CLS : LOCATE 7, 25: PRINT "BUSINESS CONTACTS DATABASE"
- LOCATE 8, 25: PRINT "AND AUTODIALER"
- LOCATE 11, 25: PRINT "------------ MAIN MENU -------------"
- LOCATE 14, 25: PRINT "1. ADD a name to the database"
- LOCATE 16, 25: PRINT "2. SEARCH for a name in the database"
- LOCATE 18, 25: PRINT "3. QUIT this program"
- LOCATE 21, 25: PRINT "Please enter 1, 2, or 3"
-
- ' Get the user's choice
- DO: choice$ = INKEY$
- LOOP UNTIL choice$ = "1" OR choice$ = "2" OR choice$ = "3"
-
- SELECT CASE choice$
- CASE "1" ' Add a name to the database
- AddName
- CASE "2" ' Search for a name in the database
- SearchName
- CASE "3" ' Quit the program and return to DOS
- SYSTEM
- END SELECT
- GOTO MainMenu:
-
- SUB AddName
- OPEN filename$ FOR APPEND AS #1
- WHILE UCASE$(last$) <> "END"
- CLS : LOCATE 11, 25: PRINT "ADD a name to the database"
- LOCATE 12, 25: PRINT "(To stop, enter END as a last name)"
- LOCATE 14, 25: INPUT "Last name:"; last$
- IF UCASE$(last$) <> "END" THEN
- LOCATE 16, 24: INPUT "First name:"; first$
- LOCATE 18, 25: INPUT "Area code:"; area$
- LOCATE 20, 22: INPUT "Phone number:"; phone$
- WRITE #1, last$, first$, area$, phone$: CLS
- END IF
- WEND
- CLOSE #1: last$ = ""
-
- END SUB
-
- SUB DialNumber
- LOCATE 3, 15: PRINT "Make sure your modem is turned on!"
- LOCATE , 15: PRINT "You must pick up the handset by the second ring."
- GetInput:
- LOCATE 7, 15: PRINT "(Enter 0 to cancel and return to main menu.)"
- LOCATE 6, 66: PRINT " ": LOCATE 6, 15
- INPUT "Enter the number of the person you'd like to call: ", choice%
-
- IF choice% < 0 OR choice% > NumNames% THEN
- LOCATE 5, 11
- PRINT "--->Please enter a number between 0 and"; NumNames%
- GOTO GetInput
- END IF
-
- IF choice% = 0 THEN GOTO SkipIt
- CLS : LOCATE 3, 15: PRINT "Dialing: ";
- PRINT Name$(2, choice%); " "; Name$(1, choice%); " ";
- IF Name$(3, choice%) = HomeAC$ THEN Name$(3, choice%) = ""
- IF Name$(3, choice%) <> "" THEN
- PhoneNum$ = "1," + Name$(3, choice%)
- PRINT "("; Name$(3, choice%); ")-";
- END IF
- PRINT Name$(4, choice%)
-
- ' If needed, insert routine to prompt the user to dial 1 first here
-
- PhoneNum$ = PhoneNum$ + Name$(4, choice%)
- OPEN "com1:1200,e,7,1,BIN,CD0,CS0,DS0,OP0" FOR RANDOM AS #2
- PRINT #2, "ATS7=9DT", PhoneNum$
- LOCATE 5, 15: PRINT "Press ESC at any time to cancel."
- LOCATE 7, 15: PRINT "Pick up the phone before the second ring."
- LOCATE 9, 15
- PRINT "After picking up the phone, press any key to continue."
- DO: LOOP UNTIL INKEY$ <> ""
-
- PRINT #2, "ATS7=30": CLOSE #2
-
- SkipIt:
- END SUB
-
- SUB SearchName
- form$ = "\ \ \ \ (\ \)-\ \"
- NumNames% = 0: search$ = "": hit% = 0
- OPEN filename$ FOR INPUT AS #1
- CLS : LOCATE 4, 15: PRINT "SEARCH for a name in the database"
- LOCATE 7, 15: INPUT "Name to search for:"; search$: PRINT
-
- DO WHILE (NOT EOF(1))
- INPUT #1, last$, first$, area$, phone$
- test$ = UCASE$(search$)
- IF UCASE$(last$) = test$ OR UCASE$(first$) = test$ THEN
- hit% = 1: NumNames% = NumNames% + 1
- Name$(1, NumNames%) = last$: Name$(2, NumNames%) = first$
- Name$(3, NumNames%) = area$: Name$(4, NumNames%) = phone$
- LOCATE , 15: PRINT NumNames%; "- ";
- PRINT USING form$; last$; first$; area$; phone$
- END IF
- LOOP
-
- IF hit% <> 0 THEN DialNumber
-
- IF hit% = 0 THEN
- LOCATE , 15: PRINT "No match found for "; search$
- LOCATE , 15: PRINT "Press any key to continue"
- DO WHILE INKEY$ = "": LOOP
- END IF
-
- CLOSE #1
-
- END SUB
-
-